package com.linkoog.devtools.case_switch;

import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;


public class CaseSwitchActionGroup extends DefaultActionGroup {

    public CaseSwitchActionGroup() {
        super();
    }


    @Override
    public void update(@NotNull AnActionEvent event) {
        super.update(event);
        Presentation presentation = event.getPresentation();
        presentation.setPopupGroup(true);
        Editor editor = event.getData(PlatformDataKeys.EDITOR);
        if (editor == null) {
            presentation.setVisible(false);
            return;
        }

        PsiFile selectedFile = event.getData(LangDataKeys.PSI_FILE);
        if (selectedFile == null || selectedFile.isDirectory()){
            presentation.setVisible(false);
            return;
        }

        presentation.setVisible(true);
    }

    @Override
    public @NotNull ActionUpdateThread getActionUpdateThread() {
        return ActionUpdateThread.BGT;
    }

}
